home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / answrbok / 5_5.lha / 5_5 / 5_5e3.c < prev    next >
Text File  |  1993-08-08  |  628b  |  32 lines

  1. * Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
  2. * The C++ Answer Book */
  3. * Tony Hansen */
  4. * All rights reserved. */
  5. tatic tree* get_expr(istream& input)
  6.  
  7.    tree* left = term(input);
  8.  
  9.    for (;;)
  10. switch (curr_tok.type)
  11.     {
  12.     case PLUS:
  13.         plus_op *headp = new plus_op;
  14.     headp->left = left;
  15.     get_token(input);    // eat '+'
  16.     headp->right = term(input);
  17.     left = headp;
  18.     break;
  19.  
  20.     case MINUS:
  21.     binary_minus_op* headm = new binary_minus_op;
  22.     headm->left = left;
  23.     get_token(input);    // eat '-'
  24.     headm->right = term(input);
  25.     left = headm;
  26.     break;
  27.  
  28.     default:        // collapse node
  29.     return left;
  30.     }
  31.  
  32.